#include "complex.h"
#include <iostream>
Complex::Complex()//constructor explicit
{
(*this).real=1.0;
(*this).imag=1.0;
}
Complex::Complex(double real,double imag)
{

(*this).real=real;
(*this).imag=imag;
}
Complex Complex::operator+(Complex z){
double real;
double imag;

real=(*this).real+z.getReal();
imag=(*this).imag+z.getImag();

Complex s=Complex(real,imag);
return s;
}
Complex Complex::operator+(double z){
double real;
double imag;
real=(*this).real+z;
imag=(*this).imag;
Complex s=Complex(real,imag);
return s;
}
Complex Complex::operator -(Complex z){
double real;
double imag;

real=(*this).real-z.getReal();
imag=(*this).imag-z.getImag();

Complex s=Complex(real,imag);

return s;
}
Complex Complex::operator -(double z){
double real;
double imag;

real=(*this).real-z;
imag=(*this).imag;

Complex s=Complex(real,imag);

return s;

}
Complex Complex::operator *(Complex z){
double real;
double imag;

real=((*this).real*z.getReal())-((*this).imag*z.getImag());
imag=((*this).real*z.getImag())+((*this).imag*z.getReal());

Complex s=Complex(real,imag);

return s;

}
Complex Complex::operator *(double z){
double real;
double imag;
real=(*this).real*z;
imag=(*this).imag;

Complex s=Complex(real,imag);

return s;
}
Complex Complex::operator /(Complex z){
double real;
double imag;

real=(((*this).real*z.getReal())+((*this).imag*z.getImag()))/((z.getReal()*z.getReal())+(z.getImag()*z.getImag())); //z.re= ((z1.re*z2.re)+(z1.im*z2.im))/((z2.re*z2.re)+(z2.im*z2.im));
imag=(((*this).imag*z.getReal())-((*this).real*z.getImag()))/((z.getReal()*z.getReal())+(z.getImag()*z.getImag()));//((z1.im*z2.re)-(z1.re*z2.im))/((z2.re*z2.re)+(z2.im*z2.im));

Complex s=Complex(real,imag);

return s;

}
Complex Complex::operator /(double z){
double real;
double imag;

real=(*this).real/z;
imag=(*this).imag;

Complex s=Complex(real,imag);

return s;

}
Complex Complex::operator ^(double z){
double real=(*this).real;
double imag=(*this).imag;
Complex s=Complex(real,imag);
while(z!=1)
	{
		s=s*s;
	z--;
	}
return s;
}
bool Complex::operator <(Complex z){
if((((*this).real*(*this).real)+((*this).imag*(*this).imag)) < ((z.getReal()*z.getReal())+(z.getImag()*z.getImag())))
	return 1;
return 0;
}
bool Complex::operator <(double z){
if ((((*this).real*(*this).real)+((*this).imag*(*this).imag)) < z)
	return 1;
return 0;
}
bool Complex::operator <=(Complex z){

	if((((*this).real*(*this).real)+((*this).imag*(*this).imag)) <= ((z.getReal()*z.getReal())+(z.getImag()*z.getImag())))
	return 1;
return 0;
}
bool Complex::operator <=(double z){
if ((((*this).real*(*this).real)+((*this).imag*(*this).imag)) <= (z*z))
	return 1;
return 0;
}
bool Complex::operator >(Complex z){
if((((*this).real*(*this).real)+((*this).imag*(*this).imag)) > ((z.getReal()*z.getReal())+(z.getImag()*z.getImag())))
	return 1;
return 0;
}
bool Complex::operator >(double z){
if ((((*this).real*(*this).real)+((*this).imag*(*this).imag)) > z)
	return 1;
return 0;
}
bool Complex::operator >=(Complex z){
if((((*this).real*(*this).real)+((*this).imag*(*this).imag)) >= ((z.getReal()*z.getReal())+(z.getImag()*z.getImag())))
	return 1;
return 0;
}
Complex Complex::operator ++(){
double real;
double imag;
real=++(*this).real;
imag=++(*this).imag;
Complex s=Complex(real,imag);
return s;
}
Complex Complex::operator --(){
double real;
double imag;

real=--(*this).real;
imag=--(*this).imag;


Complex s=Complex(real,imag);
return s;
}
double Complex::getReal(){
	double real;
	real=(*this).real;
	return real;
}
double Complex::getImag(){
	double imag;
	imag=(*this).imag;
	return imag;
}
void Complex::setReal(double real){
	(*this).real=real;
}
void Complex::setImag(double imag){
	(*this).imag=imag;
}

std::ostream &operator <<(std::ostream& iesire,Complex p){
iesire<<p.real<<" "<<p.imag;
return iesire;

}
std::istream &operator >>(std::istream& intrare,Complex &p){

std::cout<<"Re= ";
intrare>>p.real;
std::cout<<"Imag= ";
intrare>>p.imag;
return intrare;
}
Complex::Complex (const Complex *z)
{
(*this).real = z->real; 
(*this).imag = z->imag;
}
Complex::Complex (const Complex &z)
{
(*this).real = z.real;
(*this).imag = z.imag;
}

